//
//  ZYCAttendanceSummaryCell.m
//  ZDSC
//
//  Created by 张威 on 2021/10/19.
//

#import "ZYCAttendanceSummaryCell.h"
#import "ZYCAttendanceSummaryDetailModel.h"

@interface ZYCAttendanceSummaryCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIImageView *arrowImageView;
@end
@implementation ZYCAttendanceSummaryCell


- (void)setTitleString:(NSString *)titleString{
    _titleString = titleString;
    _titleLabel.text = titleString;
}

- (void)setContentString:(NSString *)contentString{
    _contentString = contentString;
    _contentLabel.text = contentString;
}
- (void)setModel:(ZYCAttendanceSummaryDetailModel *)model{
    _model = model;
    _titleLabel.text = model.teacherName;
    if ([self.status integerValue] == 1) {
        _contentLabel.text = [NSString stringWithFormat:@"正常出勤%@天",model.countStatus];
    }else if([self.status integerValue] == 2){
        _contentLabel.text = [NSString stringWithFormat:@"迟到%@次",model.countStatus];
    }else if([self.status integerValue] == 3){
        _contentLabel.text = [NSString stringWithFormat:@"早退%@次",model.countStatus];
    }else if([self.status integerValue] == 4){
        _contentLabel.text = [NSString stringWithFormat:@"缺卡%@次",model.countStatus];
    }else if([self.status integerValue] == 5){
        _contentLabel.text = [NSString stringWithFormat:@"请假%.1f天",[model.durationLeave floatValue]];
    }else if([self.status integerValue] == 6){
        _contentLabel.text = [NSString stringWithFormat:@"加班%.1f小时",[model.workOvertimeLeave floatValue]];
    }
}

- (CGFloat)getNumWithString:(NSString *)string{
    NSCharacterSet * set =[[NSCharacterSet decimalDigitCharacterSet] invertedSet];
    CGFloat second = [[string stringByTrimmingCharactersInSet:set] floatValue];
    return second;
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.contentLabel];
        [self.contentView addSubview:self.arrowImageView];
    
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.centerY.equalTo(self.contentView);
        }];

        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.arrowImageView.mas_left).offset(-20);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-15.0f);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(7, 12));
        }];
        
    }
    return self;
}



- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"jt"]];
    }
    return _arrowImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _contentLabel;
}
@end
